<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        new Promise((resolve,reject)=>{
            console.log("开始请求a数据...");
            try{
                setTimeout(()=>{
                    console.log("a数据请求成功");
                    const username = {
                        name : "张三"
                    }
                    resolve(username)
                },1800)
            }catch(e){
                reject(e.message)
            }
        })

        .then(value =>{
            return new Promise((resolve,reject)=>{
                console.log("开始请求b数据...");
                try{
                    setTimeout(()=>{
                        console.log("b数据请求成功");
                        const age = {
                            age : 80
                        }
                        resolve({
                            ...value,
                            ...age
                        })
                    },1800)
                }catch(e){
                    reject(e.message)
                }
            })
        })

        .then(value =>{
            return new Promise((resolve,reject)=>{
                console.log("开始请求c数据...");
                throw new Error("我说你错了")
                try{
                    setTimeout(()=>{
                        console.log("c数据请求成功");
                        const sex = {
                            sex : "男"
                        }
                        resolve({
                            ...value,
                            ...sex
                        })
                    },1800)
                }catch(e){
                    reject(e.message)
                }
            })
        })

        .then(value =>{
            return new Promise((resolve,reject)=>{
                console.log("开始请求d数据...");
                try{
                    setTimeout(()=>{
                        console.log("d数据请求成功");
                        const hobby = {
                            hobby : "唱,跳,rop"
                        }
                        // resolve({
                        //     ...value,
                        //     ...hobby
                        // })
                        resolve(Object.assign({},value,hobby))
                    },1800)
                }catch(e){
                    reject(e.message)
                }
            })
        })

        .then(value =>{
            //打印请求回来的数据
            console.log(value);
        })

        .catch(reason =>{
            console.log("你就是错了");
        })
        
    </script>
</body>
</html>